package com.jpcc.vw.onlineRadio.receiver;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.CustomIntent;
import android.content.Intent;
import android.text.TextUtils;

import com.jpcc.vw.onlineRadio.constants.Constants;
import com.jpcc.vw.onlineRadio.service.PlayAlbumRadioService;
import com.jpcc.vw.onlineRadio.utils.ServiceUtils;

public class TileReceiver extends BroadcastReceiver {
    @Override
    public void onReceive(Context context, Intent intent) {
        String action = intent.getAction();
        if (CustomIntent.ACTION_LINUX2ANDROID_COMMAND.equals(action)) {

//            Constants.NeedInitDataFlag=false;
//            Logger.i(CustomIntent.EXTRA_COMMAND+"----->"+intent.getStringExtra(CustomIntent.EXTRA_COMMAND));
//            Logger.i(CustomIntent.EXTRA_REQUEST_ID+"----->"+intent.getStringExtra(CustomIntent.EXTRA_REQUEST_ID));
//            ToastUtils.show(intent.getStringExtra(CustomIntent.EXTRA_REQUEST_ID));
//            Constants.LastModeFlag=false;



            if(!TextUtils.isEmpty(intent.getStringExtra(CustomIntent.EXTRA_COMMAND))){
//                Constants.LastModeFlag=false;
                Intent intentServcie = new Intent(context, PlayAlbumRadioService.class);
                intentServcie.putExtra(CustomIntent.EXTRA_COMMAND,intent.getStringExtra(CustomIntent.EXTRA_COMMAND));
                intentServcie.putExtra(CustomIntent.EXTRA_REQUEST_ID,intent.getStringExtra(CustomIntent.EXTRA_REQUEST_ID));
                intentServcie.setAction(CustomIntent.ACTION_LINUX2ANDROID_COMMAND);
//                if (ServiceUtils.isServiceWork(context, "com.jpcc.vw.onlineRadio.service.PlayAlbumRadioService")) {
                    context.startForegroundService(intentServcie);
//                }
            }
        }
    }
}
